<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="static/easyui/themes/icon.css">
<link rel="stylesheet" href="static/css/style.css" />
<link rel="stylesheet" href="static/css/tcommon.css" />
<script src="static/jquery/jquery-1.12.4.js"></script>
<script src="static/easyui/jquery.easyui.min.js"></script>
<script src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
</head>

<body>
<div class="content-container" data-options="region:'center'">
<div class="panel-header"><div class="panel-title">系统日志</div></div>
		<table id="log_table" class="easyui-datagrid" style="height: 100%"></table>
	
	<div id="toolbar">
		<div style="padding-bottom: 10px;">
			起始日期：
			<input id="fromDate" class="easyui-datebox" editable="false"/>
			终止日期：
			<input id="toDate" class="easyui-datebox" editable="false" />
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="searchLog()">搜索</a>
		</div>
	</div>
	</div>
	<div id="logDetailDlg" class="easyui-dialog info_dialog" style="width: 80%; height: 70%; padding: 10px 20px"
		closed="true">
		<form id="logDetailFm" method="post">
			<div class="content_container">
				<table class="content_table">
					<tr>
						<td width="100px;">错误方法</td>
						<td>
							<input type="text" id="detail_method" name="detail_method" readonly="readonly" style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td>调用参数</td>
						<td>
							<input type="text" id="detail_params" name="detail_params" readonly="readonly" style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td>异常代码</td>
						<td>
							<input class="easyui-textbox" data-options="multiline:true" id="detail_code" name="detail_code"
								readonly="readonly" style="width: 100%; height: 100px;">
						</td>
					</tr>
					<tr>
						<td>异常信息</td>
						<td>
							<input class="easyui-textbox" data-options="multiline:true" id="detail_info" name="detail_info"
								readonly="readonly" style="width: 100%; height: 200px;">
						</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
</body>
<script>
	var fromDate = ""; // 搜索中的日志
	var toDate = ""; // 搜索中的日期
	$(document).ready(function() {
		$('#log_table').datagrid({
			url : 'log',
			method : 'get',
			pageSize : 15,
			queryParams : {
				fromDate : fromDate,
				toDate : toDate
			},
			toolbar : '#toolbar',
			rownumbers : true,
			fitColumns : true,
			remoteSort : false,
			multiSort : true,
			border : false,
			singleSelect : true,
			pagination : true,
			striped : true,
			pageList : [ 15,20,30,40,50 ],
			/* onDblClickRow : function(index,row) {
				$("#logDetailDlg").dialog('open').dialog('setTitle', '详细信息');
				$("#logDetailFm").form('load', {
					detail_date : formatDate(row.createdate),
					detail_method : row.method,
					detail_params : row.params,
					detail_ip : row.requestip,
					detail_code : row.exceptioncode,
					detail_info : row.exceptiondetail
				});
			}, */
			columns : [ [ {
				field : 'createdate',
				title : '日期',
				width : '',
				sortable : true,
				formatter : formatDate
			},{
				field : 'description',
				title : '功能描述',
				width : '',
			},{
				field : 'method',
				title : '方法',
				width : '',
			},{
				field : 'requestip',
				title : '请求ip',
				width : '',
			},{
				field : 'username',
				title : '操作人',
				width : '',
			} ] ]
		});
	});
	function searchLog() {
		fromDate = $("#fromDate").datebox('getValue');
		toDate = $("#toDate").datebox('getValue');
		refreshTable();
	}
	function refreshTable() {
		$('#log_table').datagrid("load", {
			fromDate : fromDate,
			toDate : toDate
		});
	}
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear();
		var month = date.getMonth() + 1; //月份是从0开始的
		if (month < 10){
			month = "0" + month;
		}
		var day = date.getDate();
		if (day < 10){
			day = "0" + day;
		}
		var hour = date.getHours();
		if (hour < 10){
			hour = "0" + hour;
		}
		var min = date.getMinutes();
		if (min < 10){
			min = "0" + min;
		}
		var sec = date.getSeconds();
		if (sec < 10){
			sec = "0" + sec;
		}
		var newTime = year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + sec;
		return newTime;
	}
</script>

</html>